import enCode

def main():
    user_input = input("请输入字符串：")
    if not (0 < len(user_input) <= 255):
        print("输入的字符串长度不合法")
        return

    filtered_str = letter_filter(user_input)


    reversed_str = string_reverse(filtered_str)


    encrypted_str = enCode.caesar_cipher(reversed_str)


    print("加密后的字符串为：", encrypted_str)


def letter_filter(string):
    
    new_string = ""
    for char in string:
        if char.isalpha():
            new_string += char
    return new_string


def string_reverse(string):
    
    
    str_list = list(string)
    
    length = len(str_list)
    
    for i in range(length // 2):
        str_list[i], str_list[length - i - 1] = str_list[length - i - 1], str_list[i]
    
    return "".join(str_list)


if __name__ == "__main__":
    main()
